package com.ruoyi.web.controller.mine;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mine.domain.MyInherit;
import com.ruoyi.mine.service.IMyInheritService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 我的传承Controller
 *
 * @author ruoyi
 * @date 2024-07-29
 */
@Anonymous
@RestController
@RequestMapping("/mine/inherit")
public class MyInheritController extends BaseController
{
    @Autowired
    private IMyInheritService myInheritService;

    /**
     * 查询我的传承列表
     */
//    @PreAuthorize("@ss.hasPermi('mine:inherit:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyInherit myInherit)
    {
        startPage();
        List<MyInherit> list = myInheritService.selectMyInheritList(myInherit);
        return getDataTable(list);
    }

    /**
     * 导出我的传承列表
     */
//    @PreAuthorize("@ss.hasPermi('mine:inherit:export')")
    @Log(title = "我的传承", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MyInherit myInherit)
    {
        List<MyInherit> list = myInheritService.selectMyInheritList(myInherit);
        ExcelUtil<MyInherit> util = new ExcelUtil<MyInherit>(MyInherit.class);
        util.exportExcel(response, list, "我的传承数据");
    }

    /**
     * 获取我的传承详细信息
     */
//    @PreAuthorize("@ss.hasPermi('mine:inherit:query')")
    @GetMapping(value = "/{inheritId}")
    public AjaxResult getInfo(@PathVariable("inheritId") Long inheritId)
    {
        return success(myInheritService.selectMyInheritByInheritId(inheritId));
    }

    /**
     * 新增我的传承
     */
//    @PreAuthorize("@ss.hasPermi('mine:inherit:add')")
    @Log(title = "我的传承", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyInherit myInherit)
    {
        return toAjax(myInheritService.insertMyInherit(myInherit));
    }

    /**
     * 修改我的传承
     */
//    @PreAuthorize("@ss.hasPermi('mine:inherit:edit')")
    @Log(title = "我的传承", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyInherit myInherit)
    {
        return toAjax(myInheritService.updateMyInherit(myInherit));
    }

    /**
     * 删除我的传承
     */
//    @PreAuthorize("@ss.hasPermi('mine:inherit:remove')")
    @Log(title = "我的传承", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inheritIds}")
    public AjaxResult remove(@PathVariable Long[] inheritIds)
    {
        return toAjax(myInheritService.deleteMyInheritByInheritIds(inheritIds));
    }
}
